package com.app.datamanagermodule.dao

import androidx.paging.DataSource
import androidx.room.*
import com.app.datamanagermodule.entity.User
import io.reactivex.Completable
import io.reactivex.Single



@Dao
interface UserDao {

    @Insert
    fun insertUsers(user: User) : Single<Long>

    @Insert
    fun insertMoreUsers(users : List<User>) : Single<MutableList<Long>>

    @Update(onConflict = OnConflictStrategy.REPLACE)
    fun updateUsers(vararg users: User): Int

    @Delete
    fun deleteUsers(users: User): Completable

    @Query("select * from _user")
    fun selectAllUsers() : Single<MutableList<User>>

    @Query("select * from _user limit :count offset :index")
    fun selectUserByPosition(index: Int, count: Int) : Single<MutableList<User>>

    @Delete
    fun deleteAllUsers(users: List<User>): Completable

    @Query("select * from _user")
    fun selectAllUser() : DataSource.Factory<Int, User>

}